Lessequal ================= 逐元素计算第一个输入 (Input0) 的元素是否小于或等于第二个输入 (Input1) 的对应元素。该算子支持广播机制。 .. math:: output_i = \begin{cases} \text{True}, & \text{if } Input0_0 \le Input1_i \text{ (Input0 is broadcasted)} \\ \text{True}, & \text{if } Input0_i \le Input1_0 \text{ (Input1 is broadcasted)} \\ \text{True}, & \text{if } Input0_i \le Input1_i \text{ (No broadcast)} \\ \text{False}, & \text{otherwise} \end{cases} 输入: - **Input0** - 第一个输入数据地址。 - **Input1** - 第二个输入数据地址。 - **length** - 计算的总长度。 - **optimize** - 是否启用广播优化的标志。设置为1时启用。 - **in_elements_num0** - Input0 的元素个数。当 optimize 启用时,用于判断哪个输入是标量。 - **core_mask** - 核掩码(仅共享存储版本需要)。 输出: - **Output** - 计算结果地址。 支持平台: ``FT78NE`` ``MT7004`` .. note:: - FT78NE 支持int8, int16, int32, fp32, fp64 - MT7004 支持fp16, fp32, int16, int32 **共享存储版本:** .. c:function:: void i8_lessequal_s(int8_t* Input0, int8_t* Input1, bool* output, int length, int optimize, int in_elements_num0, int core_mask) .. c:function:: void i16_lessequal_s(int16_t* Input0, int16_t* Input1, bool* output, int length, int optimize, int in_elements_num0, int core_mask) .. c:function:: void i32_lessequal_s(int32_t* Input0, int32_t* Input1, bool* output, int length, int optimize, int in_elements_num0, int core_mask) .. c:function:: void hp_lessequal_s(half* Input0, half* Input1, bool* output, int length, int optimize, int in_elements_num0, int core_mask) .. c:function:: void fp_lessequal_s(float* Input0, float* Input1, bool* output, int length, int optimize, int in_elements_num0, int core_mask) .. c:function:: void dp_lessequal_s(double* Input0, double* Input1, bool* output, int length, int optimize, int in_elements_num0, int core_mask) **C调用示例:** .. code-block:: c :linenos: :emphasize-lines: 11 //FT78NE示例 #include #include // 假设头文件名为 less.h int main(int argc, char* argv[]) { float *input0 = (float *)0xA0000000; //input在DDR空间 float *input1 = (float *)0xB0000000; bool *output = (bool *)0xC0000000; int length = 1000; int core_mask = 0xff; // 不使用广播,optimize=0, in_elements_num0 无意义 fp_lessequal_s(input0, input1, output, length, 0, length, core_mask); return 0; } **私有存储版本:** .. c:function:: void i8_lessequal_p(int8_t* Input0, int8_t* Input1, bool* output, int length, int optimize, int in_elements_num0) .. c:function:: void i16_lessequal_p(int16_t* Input0, int16_t* Input1, bool* output, int length, int optimize, int in_elements_num0) .. c:function:: void i32_lessequal_p(int32_t* Input0, int32_t* Input1, bool* output, int length, int optimize, int in_elements_num0) .. c:function:: void hp_lessequal_p(half* Input0, half* Input1, bool* output, int length, int optimize, int in_elements_num0) .. c:function:: void fp_lessequal_p(float* Input0, float* Input1, bool* output, int length, int optimize, int in_elements_num0) .. c:function:: void dp_lessequal_p(double* Input0, double* Input1, bool* output, int length, int optimize, int in_elements_num0) **C调用示例:** .. code-block:: c :linenos: :emphasize-lines: 11 //FT78NE示例 #include #include // 假设头文件名为 less.h int main(int argc, char* argv[]) { float *scalar_input = (float *)0x10000000; // 标量输入 (input0) float *array_input = (float *)0x10001000; // 数组输入 (input1) bool *output = (bool *)0x10002000; int length = 1000; // 数组的长度 scalar_input = 5.0f; // 设置标量值 // 启用广播,比较一个标量和一个数组 fp_lessequal_p(scalar_input, array_input, output, length, 1, 1); return 0; }